home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / xmasspak / _pcx / rpcx.asm next >
Encoding:
Assembly Source File  |  1995-02-13  |  3.8 KB  |  152 lines

  1. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2. ;                                 PCX-READ
  3. ;                                ─────────
  4. ; This is a demonstration how to depack a 256 color PCX-file.
  5. ; The main-routine is called 'depack_pcx' !
  6. ; You can use this piece of code freely.......
  7. ; This routine is made to depack pictures with a resolution of 320*200 pixel.
  8. ;
  9. ;                                                      Capella/Escape
  10. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  11.  
  12. ideal
  13. model large
  14. p386n
  15. stack 256
  16.  
  17. assume cs:coding
  18.  
  19. segment  coding
  20.  
  21. start:        mov ax,pcxdata
  22.               mov ds,ax
  23.               assume ds:pcxdata
  24.                
  25.               mov ax,0a000h
  26.               mov es,ax
  27.               assume es:0a000h
  28.  
  29.               mov ax,0013h
  30.               int 10h
  31.  
  32. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  33. ;                        LOADROUTINE FOR THE PICTURE
  34. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  35.  
  36.               mov ax,3d02h
  37.               mov dx,offset file
  38.               int 21h
  39.               jc error
  40.               mov bx,ax
  41.  
  42.               mov ah,3fh
  43.               mov dx,offset puffer
  44.               mov cx,0ffffh
  45.               int 21h
  46.               jc error
  47.               sub ax,768
  48.               add ax,offset puffer
  49.               mov [ds:bitmap_end],ax
  50.  
  51.               mov ah,3eh
  52.               int 21h
  53.               jc error
  54.  
  55.               call depack_pcx
  56.  
  57.               call set_colors
  58.               
  59. warte:        in al,60h
  60.               cmp al,01h
  61.               jne warte
  62.  
  63.               mov ax,0003h
  64.               int 10h
  65.               mov ax,4c00h
  66.               int 21h
  67.  
  68. error:        mov ax,0003h
  69.               int 10h
  70.               mov dx,offset etxt
  71.               mov ah,09h
  72.               int 21h
  73.               jmp warte
  74.  
  75. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  76. ;                          THE PCX-DEPACK-ROUTINE
  77. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  78.  
  79. depack_pcx:   mov si,offset puffer
  80.               add si,128
  81.               xor di,di
  82.  
  83. depack_l2:    mov al,[ds:si]
  84.               and al,11000000b
  85.               cmp al,192
  86.               jne single_byte
  87.               
  88.               mov cl,[ds:si]
  89.               sub cl,192
  90.               xor ch,ch
  91.  
  92.               mov al,[ds:si+1]
  93. depack_l1:    mov [es:di],al
  94.               inc di
  95.               dec cx
  96.               jnz depack_l1
  97.               add si,2
  98.               cmp si,[ds:bitmap_end]
  99.               jb depack_l2
  100.  
  101.               ret
  102.  
  103. single_byte:  mov al,[ds:si]
  104.               mov [es:di],al
  105.               inc si
  106.               inc di
  107.               cmp si,[ds:bitmap_end]
  108.               jb depack_l2
  109.               ret
  110.  
  111. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  112. ;                      SET THE COLORTABLE OF THE PCX FILE
  113. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  114.  
  115. set_colors:   mov si,[ds:bitmap_end]
  116.         ;     inc si
  117.               mov dx,03c8h
  118.               xor al,al
  119.               out dx,al
  120.               inc dx
  121.               mov cx,256
  122. copy_colors:  mov al,[ds:si]
  123.               shr al,2
  124.               out dx,al
  125.               mov al,[ds:si+1]
  126.               shr al,2
  127.               out dx,al
  128.               mov al,[ds:si+2]
  129.               shr al,2
  130.               out dx,al
  131.               add si,3
  132.               dec cx
  133.               jnz copy_colors
  134.               ret
  135.  
  136.  
  137. ends  coding
  138.  
  139. segment  pcxdata
  140.  
  141. file           db "testgfx.pcx",0
  142. etxt           db "error appears.....$"
  143. bitmap_end     dw ?
  144.  
  145. puffer         db 64000 dup (?)
  146.  
  147. ends  pcxdata
  148.  
  149. end start
  150.  
  151.  
  152.